Title
library(plotly);
library(ggplot2);
library(ggfortify);
library(repr);
library(tidyr);
library(tsibble);
library(TSstudio);
library(anytime);
library(zoo);
Using adjusted
dataset = read.csv("dataset/stockholm_monthly_mean_temperature_1980_2020_adjust.csv", sep=';')
#rownames(dt) = as.integer(as.character(dt$year))
min_year = min(dataset$year)
max_year = max(dataset$year)
#dt = dt[,-1]
head(dataset)
train = ts(as.vector(t(as.matrix(dataset[,-1]))), start=c(1980, 1), end=c(max_year, 12), frequency =12)
dt_reshape <- data.frame(date=as.Date(as.yearmon(time(train))), temp=as.matrix(train))
#dt_reshape <- dataset %>% pivot_longer(cols=jan:dec, names_to = "month", values_to = "temp") %>%
# unite(date, c(year, month))
#dt_reshape$date <- anydate(dt_reshape$date)
#print(dt_reshape)
head(dt_reshape)
options(repr.plot.width=15, repr.plot.height=8)
autoplot(train, xlab="Year", ylab="Temperature (°C)")+
ggtitle("Monthly Mean Air Temperature (°C), Stockholm 1980-2020")+
theme(plot.title = element_text(size = 35, face = "bold")) +
guides(colour = guide_legend(title.hjust = 20))
fig <- plot_ly(dt_reshape, x = ~date, y = ~temp, type = 'scatter', mode = 'lines') %>%
layout(title = 'Monthly Mean Air Temperature (°C)', plot_bgcolor = "#e5ecf6")
fig
boxplot(train~cycle(train), names=month.abb, xlab="", ylab="Temperature (°C)")
fig <- plot_ly(dt_reshape, y=~temp, type = "box")
fig
# https://stackoverflow.com/questions/40622933/rplotly-creating-multiple-boxplots-in-one-graph-as-a-group
For example, a root near 1 of the autoregressive polynomial suggests that the data should be differenced before fitting an ARMA model, whereas a root near 1 of the moving-average polynomial indicates that the data were overdifferenced.